<?php
    require  '../db.func.php';
    require '../tools.func.php';
    $id=getsession('id','shop');
    $prefix=getprefix();
    $sql="SELECT quantity,price,products FROM  {$prefix}cart WHERE uid='{$id}' ";
    $res=queryone($sql);
   
    if($res){
        $products=$res['products'];
        $quantity=$res['quantity'];
        $price=$res['price'];
        $date=date('Y-m-d H:i:s');
        $sql="INSERT INTO {$prefix}order(quantity,price,products,uid,created_at) 
                VALUES('$quantity','$price','$products','$id','$date') ";
        
        execute($sql);
        header('location:checkout.html');

    }
    else{
        header('location:index.php');
    }